package entities;



import java.io.Serializable;

import javax.persistence.*;

import dto.PackageDTO;

/**
 * Entity implementation class for Entity: PackageEntity
 *
 */
@Entity
@Table(name="PACKAGES")
@NamedQueries({
	@NamedQuery(name=PackageEntity.FIND_ALL,
				query="SELECT p FROM PackageEntity p"),
	@NamedQuery(name=PackageEntity.FIND_FOR_USER,
				query="SELECT p FROM PackageEntity p WHERE p.available=1 AND p.disponibility > 0 AND p.modified =0")
	}
		)
public class PackageEntity implements Serializable 
{
	private static final long serialVersionUID = 1L;
	
	public static final String FIND_ALL = "PackageEntity.findAll";
	public static final String FIND_FOR_USER="PackageEntity.findForUser";
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private long id;
	
	private boolean available;
	
	private Integer disponibility;
	
	private Float price;
	
	private Integer discount;
	
	private boolean modified;
	
	@ManyToOne
	private ExcursionEntity excursion; 
	@ManyToOne
	private ResidenceEntity residence;
	@ManyToOne
	private TransportEntity departureTransport;
	@ManyToOne
	private TransportEntity returnTransport;
	
	private String admin;
	
	public PackageEntity() {
		super();
	}
	
	public PackageEntity(PackageDTO dto) {
		this.id=dto.getId();
		this.available=dto.isAvailable();
		this.disponibility=dto.getDisponibility();
		this.price=dto.getPrice();
		this.discount=dto.getDiscount();
		this.modified=dto.isModified();
		this.excursion = new ExcursionEntity(dto.getExcursion());
		this.residence = new ResidenceEntity(dto.getResidence());
		this.departureTransport = new TransportEntity(dto.getDepartureTransport());
		this.returnTransport = new TransportEntity(dto.getReturnTransport());
		this.admin= dto.getAdmin();
	}
	
	public long getId()
	{
		return id;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	

	public boolean isAvailable() {
		return available;
	}

	public void setAvailable(boolean available) {
		this.available = available;
	}

	public Integer getDisponibility() {
		return disponibility;
	}

	public void setDisponibility(Integer disponibility) {
		this.disponibility = disponibility;
	}

	public Float getPrice() {
		return price;
	}

	public void setPrice(Float price) {
		this.price = price;
	}

	public Integer getDiscount() {
		return discount;
	}

	public void setDiscount(Integer discount) {
		this.discount = discount;
	}

	public boolean isModified() {
		return modified;
	}

	public void setModified(boolean modified) {
		this.modified = modified;
	}

	public ExcursionEntity getExcursion() {
		return excursion;
	}

	public void setExcursion(ExcursionEntity excursion) {
		this.excursion = excursion;
	}

	public ResidenceEntity getResidence() {
		return residence;
	}

	public void setResidence(ResidenceEntity residence) {
		this.residence = residence;
	}

	public TransportEntity getDepartureTransport() {
		return departureTransport;
	}

	public void setDepartureTransport(TransportEntity departureTransport) {
		this.departureTransport = departureTransport;
	}

	public TransportEntity getReturnTransport() {
		return returnTransport;
	}

	public void setReturnTransport(TransportEntity returnTransport) {
		this.returnTransport = returnTransport;
	}

	
	
	public String getAdmnin() {
		return admin;
	}

	public void setAdmnin(String admnin) {
		this.admin = admnin;
	}

	@Override
	public String toString() {
		return "PackageEntity [id=" + id + ", available=" + available
				+ ", disponibility=" + disponibility + ", price=" + price
				+ ", discount=" + discount + ", modified=" + modified
				+ ", excursion=" + excursion + ", residence=" + residence
				+ ", departureTransport=" + departureTransport
				+ ", returnTransport=" + returnTransport + ", admnin=" + admin
				+ "]";
	}


	

	

   
}
